package btree;

import btree.base.TreeNode;

/**
 * 给你一棵二叉树的根节点 root ，翻转这棵二叉树，并返回其根节点。
 */
public class Solution_226 {
    public TreeNode invertTree(TreeNode root) {
        dfsInvertTree(root);
        return root;
    }

    public void dfsInvertTree(TreeNode root) {
        TreeNode treeNode;
        if (root == null) return;
        treeNode = root.left;
        root.left = root.right;
        root.right = treeNode;
        dfsInvertTree(root.left);
        dfsInvertTree(root.right);
    }
}
